package com.lydia.service;

/**
 * @author Admin
 */

public enum MysqlColumnType {
    VARCHAR("VARCHAR","VARCHAR","VARCHAR"),
    VARCHAR_TEXT("VARCHAR_TEXT","VARCHAR","TEXT"),
    TEXT("TEXT","TEXT","TEXT"),
    LONGTEXT("LONGTEXT","TEXT","TEXT"),
    TINYINT("TINYINT","INT","INT"),
    INT("INT","INT","INT"),
    BIGINT("BIGINT","INT","BIGINT"),
    DOUBLE("DOUBLE","NUMBER","NUMERIC"),
    DECIMAL("DECIMAL","NUMBER","NUMERIC"),
    FLOAT8("FLOAT8","NUMBER","FLOAT8"),
    DATE("DATE","DATE","TIMESTAMP"),
    DATETIME("DATETIME","DATETIME","TIMESTAMP"),
    TIMESTAMP("TIMESTAMP","TIMESTAMP","TIMESTAMP"),
    CHAR("CHAR","CHAR","CHAR"),
    SMALLINT("SMALLINT","SMALLINT","SMALLINT"),
    BINARY("BINARY","FLOAT","FLOAT"),
    FLOAT("FLOAT","FLOAT","FLOAT"),
    FLOAT_PRECISION("FLOAT_PRECISION","FLOAT","NUMERIC"),
    BINARY_DOUBLE("BINARY_DOUBLE","DOUBLE","DOUBLE PRECISION"),
    LONGBLOB("LONGBLOB","VARBINARY","BYTEA"),
    RAW("RAW","VARBINARY","BYTEA"),
    BLOB("BLOB","BLOB","TEXT"),
    CLOB("CLOB","CLOB","TEXT"),
    NCLOB("NCLOB","CLOB","TEXT"),
    LONG("LONG","LONG","TEXT"),
    MEDIUMTEXT("MEDIUMTEXT","LONG","TEXT"),
    BFILE("BFILE","BLOB","TEXT"),
    BIT("BIT","CHAR(1)","BOOL"),
    ENUM("ENUM","VARCHAR","VARCHAR");

    String oracleType;
    String mysqlType;
    String postgresType;
    MysqlColumnType(String mysqlType, String oracleType, String postgresType) {
        this.oracleType = oracleType;
        this.mysqlType = mysqlType;
        this.postgresType = postgresType;
    }

    public String mysqlType() {
        return mysqlType;
    }


    public static String getOracleType(String  mysqlType){
        for (MysqlColumnType sourceEnum : MysqlColumnType.values()){
            if (sourceEnum.mysqlType().equals(mysqlType)){
                return sourceEnum.oracleType;
            }
        }
        return null;
    }
    public static String getPostgresType(String  mysqlType){
        for (MysqlColumnType sourceEnum : MysqlColumnType.values()){
            if (sourceEnum.mysqlType().equals(mysqlType)){
                return sourceEnum.postgresType;
            }
        }
        return null;
    }
}
